<template>
	<view>
<navigator class="uni-media-list bl p10" :url="'/pages/www/t?id='+newitem['id']" :open-type="opentype">
	<view class="uni-media-list-body"><view class="uni-media-list-text-top"><rich-text :nodes="thistext"></rich-text></view>
	<view class="huise"><text class="red">{{distance}}KM</text> - {{timestr}}</view></view>
	<block v-if="newitem['img']">
	<view class="uni-media-list-logo2"><image style="width:160upx;height:160upx;" mode="aspectFill" lazy-load="true" :data-src="imgswt+newitem['img']+anz" :src="imgswt+newitem['img']+anz"></image></view></block>
	<block v-else><view class="uni-media-list-logo2"><image style="width:160upx;height:160upx;" mode="aspectFill" lazy-load="true" :data-src="'https://09love.44api.com/img/'+newitem['id']%59+'.jpg'" :src="'https://09love.44api.com/img/'+newitem['id']%59+'.jpg'"></image></view></block>
	</navigator></view>
</template>

<script>
	function escape2Html2(str) {
	    str=str.replace(/[\n]+/gi,"<br>")
	    str=str.replace(/<\/?p>/gi,"<br>")
	    str=str.replace(/<\/?strong>/gi,"")	
	    var arrEntities={'times':'×','deg':'°','plusmn':'±','sup2':'²','sup3':'³'};
	    return str.replace(/&(times|deg|plusmn|sup2|sup2);/ig,function(all,t){return arrEntities[t];});
	   }
	var regTrim = function(s){
	    var imp = /[\^\.\\\|\(\)\*\+\-\$\[\]\?]/g;
	    var imp_c = {};
	    imp_c["^"] = "\\^";
	    imp_c["."] = "\\.";
	    imp_c["\\"] = "\\\\";
	    imp_c["|"] = "\\|";
	    imp_c["("] = "\\(";
	    imp_c[")"] = "\\)";
	    imp_c["*"] = "\\*";
	    imp_c["+"] = "\\+";
	    imp_c["-"] = "\\-";
	    imp_c["$"] = "\$";
	    imp_c["["] = "\\[";
	    imp_c["]"] = "\\]";
	    imp_c["?"] = "\\?";
	    s = s.replace(imp,function(o){
	        return imp_c[o];
	    });
	    return s;
	};
export default {
	props: { newitem: {
            type: Object,
            default: {}
        },'lc': {
          
            default:false
        },'q': {
            type:String,
            default:''
        },'opentype': {
            type:String,
            default:'navigate'
        },
		},
	 computed: {
		 distance(){
			 if(this.lc==false) return 'NAN'
return getApp().globalData.ysv8set.GetDistance(this.lc,this.newitem.lc)
		 },
	 thistext(){ 
  var t=[],e=[],n=[]
var r=escape2Html2(this.newitem.title)
this.q=this.q.trim()
if(this.q !=''){
var i = 0
var reg
var arr = this.q.split(' ');
for (i = 0; i < arr.length; i++) {
if(arr[i] !=''){
reg= new RegExp(regTrim(arr[i]), "g");
r=r.replace(reg,'<b>-'+ i + '-</b>')
}
}
for (i = 0; i < arr.length; i++) {
if(arr[i] !=''){
reg = new RegExp(regTrim('-'+ i + '-'), "g");
r=r.replace(reg,arr[i] )
}
}
}
e=[]
var a=r.toString().trim().split("<br>")
for(i=0;i<a.length;i++){
var o=a[i].toString().trim().split("<b>");
n=[]
        n[0]={type:"text",text:o[0]};
        for(var c=1;c<o.length;c++){
        t=o[c].split("</b>");
        n[2*c-1]={name:"b",attrs:{style:"color:red; padding-left:3px;padding-right: 3px;"},children:[{type:"text",text:t[0]}]
        }
        n[2*c]={type:"text",text:t[1]}
        }
        e.push({name:"div",children:n});
        }
	 return e;		
	 },timestr(){
		 return getApp().globalData.ysv8set.timeStamp2String(this.newitem.btime);	 
	 }
	 },data() {
return {
anz:getApp().globalData.ysv8set.anz,
imgswt:getApp().globalData.ysv8set.imgswt,
}
				}
        
		
    }
</script>

<style>
	.uni-media-list{padding:18upx;box-sizing:border-box;display:-webkit-box;display:-webkit-flex;display:flex;width:100%;-webkit-box-orient:horizontal!important;-webkit-box-direction:normal!important;-webkit-flex-direction:row!important;flex-direction:row!important;flex-direction:row;background-color:#fff;border-bottom:thin solid #d9d7d3}
	.uni-media-list-logo2{height:180upx;width:180upx;padding-left:10upx;padding-left:10upx}
	.uni-media-list-body{display:-webkit-box;display:-webkit-flex;display:flex;-webkit-box-flex:1;-webkit-flex:1;flex:1;-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;flex-direction:column;-webkit-box-pack:justify;-webkit-justify-content:space-between;justify-content:space-between;-webkit-box-align:start;-webkit-align-items:flex-start;align-items:flex-start;overflow:hidden}
	.uni-media-list-text-top{width:520upx;line-height:1.3;font-size:34upx;color:#000}
	.huise{font-size: small;color: #919191;}
</style>
